package com.jinzecloud.blog.config;


import com.jinzecloud.blog.Interceptor.recordInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class Interceptorconfig extends WebMvcConfigurationSupport {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //可以通过此方法(addInterceptor())添加拦截器, 可以是spring提供的或者自己添加的
//        InterceptorRegistration addInterceptor = registry.addInterceptor(getRecordInterceptor());
//        // 排除配置
//        addInterceptor.excludePathPatterns("/api/user/login");
//        addInterceptor.excludePathPatterns("/loginout");
//        addInterceptor.excludePathPatterns("/error");
//
//        // 拦截配置
//        addInterceptor.addPathPatterns("/**");
    }

    @Bean
    public recordInterceptor getRecordInterceptor() {
        return new recordInterceptor();
    }
}
